# // ***************************************************************************
# // 
# // Copyright (c) Scriptimus Ex Machina.  All rights reserved.
# // 
# // Microsoft Deployment Toolkit Support Script
# //
# // File:      ZTICreateWebSite.ps1
# // 
# // Version:   1.00 
# // 
# // Purpose:   Creates DNS resource records
# // 
# // ***************************************************************************

<#
.Synopsis
   Creates a Web Site
.DESCRIPTION
 The ZTICreateWebSite.ps1 script creates the Website for the CRL distribtion point as part of the TestLab BaseConfiguration

.EXAMPLE
    ZTICreateWebSite This will create the website on a 2008R2 server

.NOTES
   Author: Andrew Barnes
   Version: 1.0
   Created: 21 November 2012
   Last updated: 21 November 2012
   Website: http:\\scriptimus.wordpress.com

#>

Param (

    $Path = "C:\CRLDist"

    )

Begin {
    
    Write-Host "Begining script"

    Import-Module WebAdministration

    }

Process {

    Write-Host "Begining script"

    #Create Folder for Certificate Revocation List

    If (!(Test-Path -Path $Path)) 
    
        {

        Write-Host "Creating $Path Folder for Certificate Revocation List "

        New-Item -Path $Path -Type Directory 

        }

    #Create New Virtual Directory
    
    Write-Host "Creating a new Virtual Directory: $Path"

    New-WebVirtualDirectory -Site "Default Web Site" -Name CRLD -PhysicalPath $Path


    #Enable Directory Browsing

    Write-Host "Enabling Directory Browsing"

    Set-WebConfigurationProperty -filter /system.webServer/directoryBrowse -name enabled -PSPath 'IIS:\Sites\Default Web Site' -Value True


    #Enable Request Filtering

    Write-Host "Enabling Request Filtering"

    Set-WebConfigurationProperty -PSPath 'IIS:\Sites\Default Web Site' -filter /system.webServer/security/requestfiltering -name allowDoubleEscaping -Value True


    #Create Web Binding
    
    Write-Host "Creating Web Binding"

    New-WebBinding -Name "Default Web Site" -IP "*" -Port 443 -Protocol https

    gci cert:\LocalMachine\My | Where-Object {$_.Subject -like "*.com"} | new-item IIS:\SslBindings\0.0.0.0!443

    }

End {
    
    Write-Host "End Script"
    
    }
